﻿using LJLNet.Application;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using LJLNet.Thread;

namespace LJLNet
{
    class Program
    {
        private static LJLNet.Application.Application application;

        static void Main(string[] args)
        {            
            //主类 主入口类（可配置）
            application = new GameContext();
            application.Setup();
           
            //绑定监听消息IP和端口号（可配置ip地址和端口号）
            IPAddress ip = IPAddress.Parse("127.0.0.1");
            EndPoint endPoint = new IPEndPoint(ip, 6000);

            //创建一个socket对象
            //寻址方式 套接字类型 协议方式  
            Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            serverSocket.Bind(endPoint);//向操作系统申请一个ip和端口号  
            Console.WriteLine("服务器端启动完成");


            //开始监听客户端的连接请求
            serverSocket.Listen(100);//最多可以接收100个客户端请求  

            //开启线程 来接收客户端请求
            BaseThread thread = new AcceptThread(application, serverSocket);
            thread.Start();

            //断开连接
        }
    }
}
